import { createStore } from "redux";

const defState: IRootState = {
  toastData:{
    isShow:false,
    message:'test',
    type:'error'
  }
};

const reducer=(state:IRootState=defState,action:IAction)=>{
  state=JSON.parse(JSON.stringify(state))
  switch(action.type){
    case 'Toast_Show':
      let payload=action.payload as IToastPayload;
      state.toastData.type=payload.type;
      state.toastData.message=payload.message;
      state.toastData.isShow=true;
      break;
      case 'Toast_Hide':
      state.toastData.isShow=false;
      break;
  }
    return state
}

const store=createStore(reducer)

export default store
